// --------------------------------------------------------------------------------------------------------------------
// <copyright file="WorkItemBase.cs" company="AzureContrib (Open source library http://azurecontrib.codeplex.com)">
//   Microsoft Public License (Ms-PL)
// </copyright>
// <summary>
//   A common base class for an <see cref="IWorkItem" /> implementation.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

using System.ComponentModel.Composition;
using AzureContrib.WindowsAzure.Diagnostics;
using AzureContrib.WindowsAzure.ServiceRuntime;

namespace AzureContrib.WindowsAzure.WorkServices
{
	/// <summary>
	/// A common base class for an <see cref="IWorkItem"/> implementation.
	/// </summary>
	public abstract class WorkItemBase : IWorkItem
	{
		/// <summary>
		/// Gets or sets the current <see cref="IRoleEnvironment"/>.
		/// </summary>
		[Import(RequiredCreationPolicy = CreationPolicy.Shared)]
		public IRoleEnvironment RoleEnvironment { get; set; }

		/// <summary>
		/// Gets or sets the current <see cref="IRoleEnvironment"/> for the instance.
		/// </summary>
		public ITrace Trace { get; set; }

		/// <summary>
		/// Gets a value indicating whether <see cref="IWorkItem.HasWork"/>.
		/// </summary>
		public abstract bool HasWork { get; }

		/// <summary>
		/// Do the actual work. <see cref="IWorkItem.DoWork"/>
		/// </summary>
		public abstract void DoWork();
	}
}